extends CharacterBody2D
@export var move := true

const SPEED = 300.0
const JUMP_VELOCITY = -400.0
var the_camera2D : Camera2D

func _ready() -> void:
	the_camera2D = $Camera2D


func _physics_process(_delta: float) -> void:
	# Add the gravity.
	if move:
		set_physics_process(true)
	else :
		set_physics_process(false)

	# Handle jump.
	if Input.is_action_just_pressed("ui_accept") and is_on_floor():
		velocity.y = JUMP_VELOCITY

	# Get the input direction and handle the movement/deceleration.
	# As good practice, you should replace UI actions with custom gameplay actions.
	var direction := Vector2.ZERO
	direction = Input.get_vector("a","d","w","s")
	if direction.length() > 0:
		velocity = direction * SPEED
	else:
		velocity.x = move_toward(velocity.x, 0, SPEED)
		velocity.y = move_toward(velocity.y, 0, SPEED)
		
	move_and_slide()
